home *** CD-ROM | disk | FTP | other *** search
- // Dynamic link library implementation of NeuroSolutions BackSynapse component
-
- #include "NSDLL.h"
-
- /*************************************************************/
- /* Macros to access the PE layers and weights in matrix form */
-
- #define in(i,j) errorIn[j+i*inCols]
- #define out(i,j) errorOut[j+i*inCols]
-
- /********************************/
- /* Backpropagation of component */
-
- __declspec(dllexport) void performBackSynapse(
- DLLData *instance, // Pointer to instance data (may be NULL)
- DLLData *dualInstance, // Pointer to the forward synapses instance data (may be NULL)
- NSFloat *errorIn, // Pointer to the input error layer of processing elements (PEs)
- int inRows, // Number of rows of PEs in the input layer (don't forget that input and output are reversed)
- int inCols, // Number of columns of PEs in the input layer
- NSFloat *errorOut, // Pointer to the output error layer
- int outRows, // Number of rows of PEs in the output layer
- int outCols, // Number of columns of PEs in the output layer
- NSFloat *input // Pointer to the output layer of the forward synapse
- )
- {
- int i,
- inCount=inRows*inCols,
- outCount=outRows*outCols,
- count=inCount<outCount? inCount: outCount;
-
- for (i=0; i<count; i++)
- errorOut[i] += errorIn[i];
- }
-
- /******************************************/
- /* Management of instance data (OPTIONAL) */
- /*
- __declspec(dllexport) DLLData *allocBackSynapse(
- DLLData *oldInstance, // Pointer to the last instance if reallocating
- DLLData *dualInstance, // Pointer to forward axonÆs instance data (may be NULL)
- int inRows, // Number of rows of PEs in the input layer
- int inCols, // Number of columns of PEs in the input layer
- int outRows, // Number of rows of PEs in the output layer
- int outCols // Number of columns of PEs in the output layer
- )
- {
- DLLData *instance = allocDLLInstance(oldInstance);
- return instance;
- }
-
- __declspec(dllexport) void freeBackSynapse(DLLData *instance)
- {
- freeDLLInstance(instance);
- }
- */
-